package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.pojo.User.ExcelUserLoginLogDto;
import com.example.demo.pojo.User.LoginLog;
import com.example.demo.pojo.User.UserLoginLogDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LoginLogMapper extends BaseMapper<LoginLog> {
    @Select("SELECT u.id, u.nick_name, u.header_url, u.status, u.role, u.create_time, ll.id as login_log_id, ll.login_time, ll.login_ip, ll.login_address, ll.login_result FROM user u INNER JOIN login_log ll ON u.id = ll.user_id")
    IPage<UserLoginLogDto> selectUserLoginLog(@Param("page") Page<UserLoginLogDto> page);

    @Select("SELECT u.id, u.nick_name, u.header_url, u.status, u.role, u.create_time, ll.id as login_log_id, ll.login_time, ll.login_ip, ll.login_address, ll.login_result FROM user u INNER JOIN login_log ll ON u.id = ll.user_id")
    List<ExcelUserLoginLogDto> selectUserLoginLog();
}
